

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>Hyperparameter Importance &mdash; Optuna 1.4.0 文档</title>
  

  
  
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
  
  
  

  
  <script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="next" title="Integration" href="integration.html" />
    <link rel="prev" title="Exceptions" href="exceptions.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home"> Optuna
          

          
          </a>

          
            
            
              <div class="version">
                1.4.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">目录</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../installation.html">安装</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">教程</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="core.html">Core</a></li>
<li class="toctree-l2"><a class="reference internal" href="cli.html">Command Line Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="distributions.html">Distributions</a></li>
<li class="toctree-l2"><a class="reference internal" href="exceptions.html">Exceptions</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Hyperparameter Importance</a></li>
<li class="toctree-l2"><a class="reference internal" href="integration.html">Integration</a></li>
<li class="toctree-l2"><a class="reference internal" href="logging.html">Logging</a></li>
<li class="toctree-l2"><a class="reference internal" href="multi_objective/index.html">Multi-objective</a></li>
<li class="toctree-l2"><a class="reference internal" href="pruners.html">Pruners</a></li>
<li class="toctree-l2"><a class="reference internal" href="samplers.html">Samplers</a></li>
<li class="toctree-l2"><a class="reference internal" href="storages.html">Storages</a></li>
<li class="toctree-l2"><a class="reference internal" href="structs.html">Structs</a></li>
<li class="toctree-l2"><a class="reference internal" href="study.html">Study</a></li>
<li class="toctree-l2"><a class="reference internal" href="trial.html">Trial</a></li>
<li class="toctree-l2"><a class="reference internal" href="visualization.html">Visualization</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">常见问题</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">Optuna</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="index.html">API Reference</a> &raquo;</li>
        
      <li>Hyperparameter Importance</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/reference/importance.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <span class="target" id="module-optuna.importance"></span><div class="section" id="hyperparameter-importance">
<h1>Hyperparameter Importance<a class="headerlink" href="#hyperparameter-importance" title="永久链接至标题">¶</a></h1>
<dl class="py function">
<dt id="optuna.importance.get_param_importances">
<code class="sig-prename descclassname">optuna.importance.</code><code class="sig-name descname">get_param_importances</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">study</span><span class="p">:</span> <span class="n"><a class="reference internal" href="study.html#optuna.study.Study" title="optuna.study.Study">optuna.study.Study</a></span></em>, <em class="sig-param"><span class="n">evaluator</span><span class="p">:</span> <span class="n">optuna.importance._base.BaseImportanceEvaluator</span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">params</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>List<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">]</span><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; Dict<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">, </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.8)">float</a><span class="p">]</span><a class="reference internal" href="../_modules/optuna/importance.html#get_param_importances"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.importance.get_param_importances" title="永久链接至目标">¶</a></dt>
<dd><p>根据给定 study 中完成的trial 来判断特定参数的重要性。</p>
<p>参数重要性以字典形式返回，其中键由参数名称及其重要性组成。重要性由浮点数表示，一个字典中所有的重要性之和为1.0该浮点数的值越高，其对应的参数也就越重要这个返回的字典属于 <a class="reference external" href="https://docs.python.org/3/library/collections.html#collections.OrderedDict" title="(在 Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.OrderedDict</span></code></a> 类，其中的元素会按照其中值的大小降序排序。</p>
<p>如果 <code class="docutils literal notranslate"><span class="pre">params</span></code> 被设置成 <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a>, 那么所有属于已完成 trial 的参数都会被评估。这意味着，条件参数不会参与评估。要获得条件参数的重要性的话，你可以向 <code class="docutils literal notranslate"><span class="pre">params</span></code> 传入一个带有参数名的 <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">list</span></code></a>.此时，只有包含了这些参数的trial才会被评估。如果没有发现满足这种条件的trial的话，Optuna将会抛出一个错误。</p>
<p>如果给定的 study 不包含已完成的 trial 的话，Optuna将会抛出一个错误。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>如果 <code class="docutils literal notranslate"><span class="pre">params</span></code> 是一个空列表，那么将会返回一个空字典</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p>参考 <a class="reference internal" href="visualization.html#optuna.visualization.plot_param_importances" title="optuna.visualization.plot_param_importances"><code class="xref py py-func docutils literal notranslate"><span class="pre">plot_param_importances()</span></code></a> 来查看如何绘制重要性的图表。</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>study</strong> -- 一个已优化完的 study.</p></li>
<li><p><strong>evaluator</strong> -- 重要性求解器。该求解器指定用于评估重要性的算法。默认情况下我们会使用 <code class="xref py py-class docutils literal notranslate"><span class="pre">MeanDecreaseImpurityImportanceEvaluator</span></code>.</p></li>
<li><p><strong>params</strong> -- 参与评估的参数名列表。如果设置成  <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a> 的话，所有的属于已完成 trial 的参数都会被评估。</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>一个  <a class="reference external" href="https://docs.python.org/3/library/collections.html#collections.OrderedDict" title="(在 Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.OrderedDict</span></code></a>  类。它的键都是被评估过重要性的参数名。</p>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>v1.3.0 版本中新加入的试验性特性。在未来的版本中，该接口可能在没有预先告知的情况下改变。 具体参见 <a class="reference external" href="https://github.com/optuna/optuna/releases/tag/v1.3.0">https://github.com/optuna/optuna/releases/tag/v1.3.0</a>.</p>
</div>
</dd></dl>

<dl class="py class">
<dt id="optuna.importance.FanovaImportanceEvaluator">
<em class="property">class </em><code class="sig-prename descclassname">optuna.importance.</code><code class="sig-name descname">FanovaImportanceEvaluator</code><a class="reference internal" href="../_modules/optuna/importance/_fanova.html#FanovaImportanceEvaluator"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.importance.FanovaImportanceEvaluator" title="永久链接至目标">¶</a></dt>
<dd><p>fANOVA 参数重要性求解器</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>依赖 <cite>fanova &lt;https://github.com/automl/fanova&gt;</cite> 包。</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p>一种便捷的评估超参数重要性的途径 &lt;<a class="reference external" href="http://proceedings.mlr.press/v32/hutter14.html">http://proceedings.mlr.press/v32/hutter14.html</a>&gt;`_.</p>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>v1.3.0 版本中新加入的试验性特性。在未来的版本中，该接口可能在没有预先告知的情况下改变。 具体参见 <a class="reference external" href="https://github.com/optuna/optuna/releases/tag/v1.3.0">https://github.com/optuna/optuna/releases/tag/v1.3.0</a>.</p>
</div>
<dl class="py method">
<dt id="optuna.importance.FanovaImportanceEvaluator.evaluate">
<code class="sig-name descname">evaluate</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">study</span><span class="p">:</span> <span class="n"><a class="reference internal" href="study.html#optuna.study.Study" title="optuna.study.Study">optuna.study.Study</a></span></em>, <em class="sig-param"><span class="n">params</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>List<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">]</span><span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; Dict<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">, </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.8)">float</a><span class="p">]</span><a class="reference internal" href="../_modules/optuna/importance/_fanova.html#FanovaImportanceEvaluator.evaluate"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.importance.FanovaImportanceEvaluator.evaluate" title="永久链接至目标">¶</a></dt>
<dd><p>根据给定 study 中完成的trial 来判断特定参数的重要性。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This method is not meant to be called by library users.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p>参考 <a class="reference internal" href="#optuna.importance.get_param_importances" title="optuna.importance.get_param_importances"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_param_importances()</span></code></a> 来看如何实现一个具体的求解器。</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>study</strong> -- 一个已优化完的 study.</p></li>
<li><p><strong>params</strong> -- 参与评估的参数名列表。如果设置成  <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a> 的话，所有的属于已完成 trial 的参数都会被评估。</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>一个  <a class="reference external" href="https://docs.python.org/3/library/collections.html#collections.OrderedDict" title="(在 Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.OrderedDict</span></code></a>  类。它的键都是被评估过重要性的参数名。</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="optuna.importance.MeanDecreaseImpurityImportanceEvaluator">
<em class="property">class </em><code class="sig-prename descclassname">optuna.importance.</code><code class="sig-name descname">MeanDecreaseImpurityImportanceEvaluator</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">n_estimators</span><span class="p">:</span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.8)">int</a></span> <span class="o">=</span> <span class="default_value">16</span></em>, <em class="sig-param"><span class="n">max_depth</span><span class="p">:</span> <span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.8)">int</a></span> <span class="o">=</span> <span class="default_value">64</span></em>, <em class="sig-param"><span class="n">random_state</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(在 Python v3.8)">int</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/optuna/importance/_mean_decrease_impurity.html#MeanDecreaseImpurityImportanceEvaluator"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.importance.MeanDecreaseImpurityImportanceEvaluator" title="永久链接至目标">¶</a></dt>
<dd><p>Mean Decrease Impurity (MDI) 参数重要性求解器。</p>
<p>该求解器会拟合一个随机森林用于根据给定的超参数设置预测目标函数值。然后特性重要性会通过 MDI 求解。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>该求解器依赖 <a class="reference external" href="https://scikit-learn.org/stable/">sklean</a>  包，它是基于 <a class="reference external" href="https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestClassifier.html#sklearn.ensemble.RandomForestClassifier.feature_importances_">sklearn.ensemble.RandomForestClassifier.feature_importances_</a> 构建的。</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n_estimators</strong> -- 随机森林中的树数目。</p></li>
<li><p><strong>max_depth</strong> -- 该随机森林中树的最大深度。</p></li>
<li><p><strong>random_seed</strong> -- 该随机森林的种子。</p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>该特性在 v1.5.0 中被作为实验特性加入。在未来的版本中，该接口可能在没有预先告知的情况下改变。具体参见 <a class="reference external" href="https://github.com/optuna/optuna/releases/tag/v1.5.0">https://github.com/optuna/optuna/releases/tag/v1.5.0</a>.</p>
</div>
<dl class="py method">
<dt id="optuna.importance.MeanDecreaseImpurityImportanceEvaluator.evaluate">
<code class="sig-name descname">evaluate</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">study</span><span class="p">:</span> <span class="n"><a class="reference internal" href="study.html#optuna.study.Study" title="optuna.study.Study">optuna.study.Study</a></span></em>, <em class="sig-param"><span class="n">params</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>List<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">]</span><span class="p">]</span></span></em><span class="sig-paren">)</span> &#x2192; Dict<span class="p">[</span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(在 Python v3.8)">str</a><span class="p">, </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#float" title="(在 Python v3.8)">float</a><span class="p">]</span><a class="reference internal" href="../_modules/optuna/importance/_mean_decrease_impurity.html#MeanDecreaseImpurityImportanceEvaluator.evaluate"><span class="viewcode-link">[源代码]</span></a><a class="headerlink" href="#optuna.importance.MeanDecreaseImpurityImportanceEvaluator.evaluate" title="永久链接至目标">¶</a></dt>
<dd><p>根据给定 study 中完成的trial 来判断特定参数的重要性。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>This method is not meant to be called by library users.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<p>参考 <a class="reference internal" href="#optuna.importance.get_param_importances" title="optuna.importance.get_param_importances"><code class="xref py py-func docutils literal notranslate"><span class="pre">get_param_importances()</span></code></a> 来看如何实现一个具体的求解器。</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">参数</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>study</strong> -- 一个已优化完的 study.</p></li>
<li><p><strong>params</strong> -- 参与评估的参数名列表。如果设置成  <a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(在 Python v3.8)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></a> 的话，所有的属于已完成 trial 的参数都会被评估。</p></li>
</ul>
</dd>
<dt class="field-even">返回</dt>
<dd class="field-even"><p>一个  <a class="reference external" href="https://docs.python.org/3/library/collections.html#collections.OrderedDict" title="(在 Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">collections.OrderedDict</span></code></a>  类。它的键都是被评估过重要性的参数名。</p>
</dd>
</dl>
</dd></dl>

</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="integration.html" class="btn btn-neutral float-right" title="Integration" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="exceptions.html" class="btn btn-neutral float-left" title="Exceptions" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Optuna Contributors.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
    <a href="../privacy.html">Privacy Policy</a>.
     


</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    <!-- Theme Analytics -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-55135190-8', 'auto');
    ga('send', 'pageview');
    </script>

    
   

</body>
</html>